import { Message } from "element-ui";
import request from '@/utils/request'
import { getLodop } from "@/api/LodopFuncs";
import global from '@/global.js'


export async function PrintDate(billID, form, formDetail, PritType) {
    // 提交数据，需要修改

    const result = await GetPrintSetData({ billID: billID });
    //const results = await GetexportHtmlData({ InterID: null, searchWhere: null })

    var LODOP = null;
    LODOP = getLodop();
    LODOP.SET_PRINT_PAGESIZE(0, result.data.Table[0].pageHeight, result.data.Table[0].pageWidth, ""); //设定纸张大小
    LODOP.PRINT_INIT(result.data.Table[0].templeteName);
    SPrint(LODOP, result.data1.Table, form, formDetail, parseInt(result.data.Table[0].pageSize), parseInt(result.data.Table[0].heightLine), PritType,null);
    LODOP.PREVIEW();




}
//套打
export function SPrint(LODOP, params, templeteData, list, pageSize, heightLine, PritType,html) {


    CPrintList(LODOP, params, templeteData, list, heightLine, pageSize, PritType);
  // CPrintListv1(LODOP, params, templeteData, list, heightLine, pageSize, PritType,html);

    return LODOP
}
//模板设计
export function templeteDesign(LODOP, params) {
    params.forEach(e => {
        if (e.type == "ADD_PRINT_TEXT") {
            LODOP.ADD_PRINT_TEXT(e.val1, e.val2, e.val3, e.val4, e.val5)
        }
        if (e.type == "ADD_PRINT_BARCODE") {
            LODOP.ADD_PRINT_BARCODE(e.val1, e.val2, e.val3, e.val4, e.val5, e.val6)
        }
        if (e.type == "ADD_PRINT_LINE") {
            LODOP.ADD_PRINT_LINE(e.val1, e.val2, e.val3, e.val4, e.val5, e.val6)
        }
        if (e.type == "ADD_PRINT_IMAGE") {
            LODOP.ADD_PRINT_IMAGE(e.val1, e.val2, e.val3, e.val4, e.val5)
        }
        if (e.type == "SET_PRINT_STYLEA") {
            LODOP.SET_PRINT_STYLEA(e.val1, e.val2, e.val3)
        }
        if (e.type == "SET_LICENSES") {
            LODOP.SET_LICENSES(e.val1, e.val2, e.val3, e.val4)
        }
    });
    return LODOP;
}




//加载头部数据
function addHeadData(LODOP, params, templeteData) {
    params = params.filter(p => {
        if (p.TextType == 1) return p;
    })
    if (templeteData) {
        var keys = getObjKeys(templeteData);
        var bl = false;
        var val5 = "";
        var valvaue = "";
        params.forEach(e => {

            bl = false;
            try {
                keys.forEach(a => {


                    //格写处理，大小写 时间 小数位数

                    if (e.val5 == null) {
                        e.val5 = "";
                    }

                    var valList = e.val5.split('.');
                    if (valList.length == 2) {
                        
                        val5 = valList[0];
                        valvaue = funtoFixed(templeteData[a], valList[1])

                    } else if (valList.length == 3) { //大写格式 LOWER.Name.2   LOWER：大写  Name 字段 2 小数位数
                        val5 = valList[1]
                        if (valList[0] == "LOWER") {
                            if (parseFloat(templeteData[a]) > 0) {
                                valvaue = priceChange(parseFloat(templeteData[a]).toFixed(valList[2]))
                            } else {
                                valvaue = "";
                            }


                        } else if (valList[0] == "Datatime") {
                            valvaue = dealWithTime(templeteData[a], valList[2]);
                        } else {
                            valvaue = item[a];
                        }


                    } else {
                        val5 = e.val5;
                        valvaue = templeteData[a]
                    }



                    if (val5 == a && e.type == "ADD_PRINT_TEXT" && bl == false) {
                        bl = true;
                        LODOP.ADD_PRINT_TEXT(e.val1, e.val2, e.val3, e.val4, valvaue)
                    }




                })

            } catch (e) {}


            if (bl == false) {

                if (e.type == "ADD_PRINT_TEXT") {
                    LODOP.ADD_PRINT_TEXT(e.val1, e.val2, e.val3, e.val4, e.val5)
                } else if (e.type == "ADD_PRINT_IMAGE") {
                    LODOP.ADD_PRINT_IMAGE(e.val1, e.val2, e.val3, e.val4, e.val5)
                } else if (e.type == "ADD_PRINT_LINE") {
                    LODOP.ADD_PRINT_LINE(e.val1, e.val2, e.val3, e.val4, e.val5, 2)
                } else if (e.type == "SET_PRINT_STYLEA") {
                    LODOP.SET_PRINT_STYLEA(e.val1, e.val2, e.val3)
                }
            }

        })
    } else {
        params.forEach(e => {
            if (e.type == "ADD_PRINT_TEXT") {
                LODOP.ADD_PRINT_TEXT(e.val1, e.val2, e.val3, e.val4, e.val5)
            } else if (e.type == "ADD_PRINT_IMAGE") {
                LODOP.ADD_PRINT_IMAGE(e.val1, e.val2, e.val3, e.val4, e.val5)

            } else if (e.type == "ADD_PRINT_LINE") {
                LODOP.ADD_PRINT_LINE(e.val1, e.val2, e.val3, e.val4, e.val5, 2)
            } else if (e.type == "SET_PRINT_STYLEA") {
                LODOP.SET_PRINT_STYLEA(e.val1, e.val2, e.val3)
            }
        })
    }
    return LODOP;
}
//加载尾部数据
function addTailData(LODOP, params, templeteData, length, heightLine,height) {
    height=height-heightLine;
  
    params = params.filter(p => {
        if (p.TextType == 3) return p;
    })

    var bl = false;
    var val5 = "";
    var valvaue = "";
    if (templeteData) {
        var keys = getObjKeys(templeteData);
        params.forEach(e => {

            bl = false;
            keys.forEach(a => {

                //格写处理，大小写 时间 小数位数

                if (e.val5 == null) {
                    e.val5 = "";
                }

                var valList = e.val5.split('.');
                if (valList.length == 2) {
                    
                    val5 = valList[0];
                    valvaue = funtoFixed(templeteData[a], valList[1])

                } else if (valList.length == 3) { //大写格式 LOWER.Name.2   LOWER：大写  Name 字段 2 小数位数
                    val5 = valList[1]
                    if (valList[0] == "LOWER") {

                        if (parseFloat(templeteData[a]) > 0) {
                            valvaue = priceChange(parseFloat(templeteData[a]).toFixed(valList[2]))
                        } else {
                            valvaue = "";
                        }



                    } else if (valList[0] == "Datatime") {
                        valvaue = dealWithTime(templeteData[a], valList[2]);
                    } else {
                        valvaue = item[a];
                    }


                } else {
                    val5 = e.val5;
                    valvaue = templeteData[a]
                }



                if (val5 == a && e.type == "ADD_PRINT_TEXT") {
                    bl = true;
                    //LODOP.ADD_PRINT_TEXT(parseInt(e.val1) + (length - 1) * heightLine, e.val2, e.val3, e.val4, valvaue)
                    LODOP.ADD_PRINT_TEXT(parseInt(e.val1) + height, e.val2, e.val3, e.val4, valvaue)

                } else if (val5 == a && e.type == "ADD_PRINT_IMAGE") {
                    bl = true;

                    if(valvaue!=null&&valvaue!='')
                    {
                       // LODOP.ADD_PRINT_IMAGE(parseInt(e.val1) + (length - 1) * heightLine, e.val2, e.val3, e.val4, "<img border='1px' src='" + valvaue + "'  />")
                        LODOP.ADD_PRINT_IMAGE(parseInt(e.val1) + height, e.val2, e.val3, e.val4, "<img border='1px' src='" + valvaue + "'  />")

                    }
                   
                }
            })

            if (bl == false) {



                if (e.type == "ADD_PRINT_TEXT") {
                    LODOP.ADD_PRINT_TEXT(parseInt(e.val1) + height, e.val2, e.val3, e.val4, e.val5)
                   // LODOP.ADD_PRINT_TEXT(parseInt(e.val1) + (length - 1) * heightLine, e.val2, e.val3, e.val4, e.val5)
                } else if (e.type == "ADD_PRINT_IMAGE") {
                    LODOP.ADD_PRINT_IMAGE(parseInt(e.val1) + height, e.val2, e.val3, e.val4, e.val5, e.val6)
                   // LODOP.ADD_PRINT_IMAGE(parseInt(e.val1) + (length - 1) * heightLine, e.val2, e.val3, e.val4, e.val5, e.val6)
                } else if (e.type == "ADD_PRINT_LINE") {

                    LODOP.ADD_PRINT_LINE(parseInt(e.val1) + height, e.val2, parseInt(e.val3) + (length - 1) * heightLine, e.val4, e.val5, 2)
                    //LODOP.ADD_PRINT_LINE(parseInt(e.val1) + (length - 1) * heightLine, e.val2, parseInt(e.val3) + (length - 1) * heightLine, e.val4, e.val5, e.val6)
                } else if (e.type == "SET_PRINT_STYLEA") {
                    LODOP.SET_PRINT_STYLEA(e.val1, e.val2, e.val3)
                }

            }

        })




    }

    return LODOP;
}


function funtoFixed(nums, num) {

    var totalNum = null;


    if (nums != null && nums != "") //为NULL 值 不转换
    {
        totalNum = (Math.round(nums * 100) / 100).toFixed(num);
    }


    return totalNum;
}


function priceChange(number) {
    var ret = "";
    if (number != "" && number != null && number != "0") {
        var unit = "仟佰拾亿仟佰拾万仟佰拾元角分",
            str = "";
        number += "00";
        var point = number.indexOf(".");
        if (point >= 0) {
            number = number.substring(0, point) + number.substr(point + 1, 2);
        }
        unit = unit.substr(unit.length - number.length);
        for (var i = 0; i < number.length; i++) {
            str +=
                "零壹贰叁肆伍陆柒捌玖".charAt(number.charAt(i)) + unit.charAt(i);
        }
        ret =
            str
            .replace(/零(仟|佰|拾|角)/g, "零")
            .replace(/(零)+/g, "零")
            .replace(/零(万|亿|元)/g, "$1")
            .replace(/(亿)万|(拾)/g, "$1$2")
            .replace(/^元零?|零分/g, "")
            .replace(/元$/g, "元") + "整";
    }
    return ret;
}　

function dealWithTime(date, format) {

    var date = new Date(date)
    var Fr = "";
    
    let Y = date.getFullYear()
    let M = date.getMonth() + 1 - 0 >= 10 ? Number(date.getMonth()) + 1 : '0' + (Number(date.getMonth()) + 1)
    let D = date.getDate() >= 10 ? date.getDate() : '0' + date.getDate()
    let h = date.getHours() >= 10 ? date.getHours() : '0' + date.getHours()
    let m = date.getMinutes() >= 10 ? date.getMinutes() : '0' + date.getMinutes()
    let s = date.getSeconds() >= 10 ? date.getSeconds() : '0' + date.getSeconds()

    if (format == "yyyy") {
        Fr = Y;
    } else if (format == "yyyy-mm") {
        Fr = Y + '-' + M
    } else if (format == "yyyy-mm-dd") {
        Fr = Y + '-' + M + '-' + D + ''
    } else {
        Fr = Y + '-' + M + '-' + D + ''
    }

    return Fr
}



//打印网页
export async function CPrintListv1(LODOP, params, templeteData, list, heightLine, pageSize, PritType,html) {

    var j = 0;
    var i = 1;
    var paramsData = null;

    if (PritType == 1) { // 连打

        LODOP.NewPage();

        addHeadData(LODOP, params, templeteData); //表头


    }

    //addHeadData(LODOP, params, templeteData); //表头
    // debugger
    
// debugger
     //LODOP.ADD_PRINT_TEXT(170,294,203,295,0,4, " fsfsfsfsdfsdf")
     LODOP.ADD_PRINT_HTM(50,0,'100%','40%', html);//mm、cm、px单位随便挑
 


    //addTailData(LODOP, params, templeteData, list.length, heightLine)
    return LODOP;

}


export async function GetexportHtmlData(data) {
    return request({
        url: '/Common/GetexportHtmlData',
        method: 'post',
        data: data
    })
}


//连打子表数据加载
function CPrintList(LODOP, params, templeteData, list, heightLine, pageSize, PritType) {

    var j = 0;
    var i = 1;
    var Pages = 1;
    var lines=0;
    var numLine=1;
    var paramsData = null;
    var RowtableData=[];
    if (PritType == 1) { // 连打

        LODOP.NewPage();

        addHeadData(LODOP, params, templeteData); //表头


    }

    addHeadData(LODOP, params, templeteData); //表头

 
    if (list && list.length) {

      
        paramsData = params.filter(p => {
            if (p.TextType == 2) return p;
        })

        var keys = getObjKeys(list[0])
        var height = 0;
        var bl = false;
        Pages=1;
//计划行高，翻页
var pageheight= pageSize*heightLine;
//debugger
        list.forEach(item => {
           



            paramsData.forEach(e => {

                bl = false;
                var val5 = "";
                var valvaue = "";
                //匹配数据值
                keys.forEach(a => {



                    //格写处理，大小写 时间 小数位数

                    if (e.val5 == null) {
                        e.val5 = "";
                    }
                var valList = e.val5.split('.');
                if (valList.length == 2) {
                    
                    val5 = valList[0];
                    valvaue = funtoFixed(item[a], valList[1])

                } else if (valList.length == 3) { //大写格式 LOWER.Name.2   LOWER：大写  Name 字段 2 小数位数
                    val5 = valList[1]
                    if (valList[0] == "LOWER") {

                        if (parseFloat(item[a]) > 0) {
                            valvaue = priceChange(parseFloat(item[a]).toFixed(valList[2]))
                        } else {
                            valvaue = "";
                        }


                    } else if (valList[0] == "Datatime") {
                        valvaue = dealWithTime(item[a], valList[2]);
                    } else {
                        valvaue = item[a];
                    }


                } else {
                    val5 = e.val5;
                    valvaue = item[a]
                }



                   if (val5 == a && e.type == "ADD_PRINT_TEXT" && bl == false) {
                    if (valList.length == 1) {
                        var b=0;
                        var num=0;
                        var numReg = /^[0-9]*$/
                        var numRe = new RegExp(numReg)
                        if (valvaue == null) {
                                        valvaue = "";
                                    }
                       
                        if (!numRe.test(valvaue)) {
                         
                             b =computedByteLen(valvaue);
                        }else
                        {
                            b=valvaue.length;
                          
                        }
                       
                        // if(valvaue=='220-240V/50-60Hz/1400W/R/SV')
                        // {
                        //     debugger
                        // }
                           
                           var s=5/(parseFloat(e.val3)/b)//计算超出比例值
                           
                           if(s>1)
                           {
                           
                            num=s
                        
                            if(numLine<s)
                            {
                             // debugger
                                       numLine=s
                            }
                          
                          
                           }
                        }
                    }


                })

          
               // debugger
               //根椐比例值算行数
               if(numLine>3)
               {
                lines = height + (heightLine*0.5)*3;
               }else if(numLine>2)
               {
                lines = height + (heightLine*0.8)*2;
               }else  if(numLine>1)
               {
                lines = height + (heightLine*0.8)*1;
               }else if(numLine==1)
               {
                lines = height + (heightLine)*0
               }else if(numLine<1)
               {
                   lines=height;
               }
                
            
          


            })

       

     
if(pageheight<=(lines)|| Pages===(pageSize)||i===list.length)
{
   
  
    if(pageheight<lines)
    {
      Pages=Pages-1;
    }else
    {
        if((i==list.length&&Pages<(pageSize))||((pageheight-lines)>heightLine))//最后一条数据时，补足打印条数
{
    
    Pages=Pages+ parseInt((pageheight-lines)/heightLine)//条数=（总行高-当前总行高）/行高


}

    }
   



 
  

    let row = {
        PageNum: j+1,
        pageSize: Pages,
        lines:lines,
        numLine:numLine
      };

      RowtableData.push(row);

      //debugger

      j++
      Pages=0;
      

      
//判断最后一页最后一条数据有没有超出高度，如果超出高度增加一页
      if(pageheight<lines&&Pages===(pageSize))
      {


        if(numLine>3)
        {
         lines = height + (heightLine*0.5)*3;
        }else if(numLine>2)
        {
         lines = height + (heightLine*0.8)*2;
        }else  if(numLine>1)
        {
         lines = height + (heightLine*0.8)*1;
        }else if(numLine==1)
        {
         lines = height + (heightLine)*0
        }else if(numLine<1)
        {
            lines=height;
        }

        row = {
            PageNum: j+2,
            pageSize: 1+parseInt((pageheight-lines)/heightLine),
            lines:lines,
            numLine:numLine
          };

          RowtableData.push(row);
          
      }
      

      

     


     


      lines=0;
      //numLine=0;

   
}
       
i++; 
Pages++;  

            height = (heightLine)+lines;
          
            numLine=1;
          
         
           
           

        })

        //111111111111111111111111111111111111111111111111
         
         j = 0;
         i = 1;
          height = 0;
          bl = false;
          Pages=0;
        list.forEach(item => {

            numLine=1;
          if(Pages==0)
          {
            pageSize=RowtableData[Pages].pageSize;
          }
        
          
            if ((j == pageSize || i == 1) && PritType == 2) { //套打翻页

                if (i != 1) {
                    LODOP.NewPage(); //新建一页
                    addHeadData(LODOP, params, templeteData); //加载表头
                    j = 0; //初始化条数
                    height = 0; //初始化高度
                    Pages++;
                    lines=0;
                    pageSize=RowtableData[Pages].pageSize;
                }
            }

           // var numLine=1;

            paramsData.forEach(e => {





                bl = false;
                var val5 = "";
                var valvaue = "";
                //匹配数据值
                keys.forEach(a => {



                    //格写处理，大小写 时间 小数位数

                    if (e.val5 == null) {
                        e.val5 = "";
                    }

                    var valList = e.val5.split('.');
                    if (valList.length == 2) {
                        
                        val5 = valList[0];
                        valvaue = funtoFixed(item[a], valList[1])

                    } else if (valList.length == 3) { //大写格式 LOWER.Name.2   LOWER：大写  Name 字段 2 小数位数
                        val5 = valList[1]
                        if (valList[0] == "LOWER") {

                            if (parseFloat(item[a]) > 0) {
                                valvaue = priceChange(parseFloat(item[a]).toFixed(valList[2]))
                            } else {
                                valvaue = "";
                            }


                        } else if (valList[0] == "Datatime") {
                            valvaue = dealWithTime(item[a], valList[2]);
                        } else {
                            valvaue = item[a];
                        }


                    } else {
                        val5 = e.val5;
                        valvaue = item[a]
                    }



                   // //自动行高************************************
if (val5 == a && e.type == "ADD_PRINT_TEXT" && bl == false) {
if (valList.length == 1) {
    var b=0;
    var num=0;
    var numReg = /^[0-9]*$/
    var numRe = new RegExp(numReg)
    if (valvaue == null) {
                    valvaue = "";
                }
   
    if (!numRe.test(valvaue)) {
     
         b =computedByteLen(valvaue);
    }else
    {
        b=valvaue.length;
      
    }
   

    var s=0;
    if(valvaue=='0煎炸一体炸锅煎1煎炸一体炸锅煎1煎炸一体炸锅煎1煎炸一体炸锅煎')
    {
        debugger
    }
    if(valvaue!=null&&valvaue!='')
    {
        s=6.7/(parseFloat(e.val3)/b)
    }
  
       
       if(s>1)
       {
       
        num=s
        if(numLine<s)
        {
           
           numLine=s
                  
        }
      
      
       }
    }
}




                    if (val5 == "Sort" && e.type == "ADD_PRINT_TEXT" && bl == false) //自增序号
                    {
                        bl = true;
                        LODOP.ADD_PRINT_TEXT(parseInt(e.val1) + height, e.val2, e.val3, e.val4, i)
                        
                    } else if (val5 == a && e.type == "ADD_PRINT_TEXT" && bl == false) {
                        bl = true;
                        LODOP.ADD_PRINT_TEXT(parseInt(e.val1) + height, e.val2, e.val3, e.val4*numLine, valvaue)//peter 2023-11-08  打印图片
                        
                    }else if (val5 == a && e.type == "ADD_PRINT_IMAGE" && bl == false&&valvaue!=null&&valvaue!='') {
                        bl = true;
                        LODOP.ADD_PRINT_IMAGE(parseInt(e.val1) + height, e.val2, e.val3, e.val4,  "<img border='1px' src='" + valvaue + "'  />")
                    }


               })



                debugger
                if(numLine>3)
                {
                 lines = height + (heightLine*0.5)*3;
                }else if(numLine>2)
                {
                 lines = height + (heightLine*0.8)*2;
                }else  if(numLine>1)
                {
                 lines = height + (heightLine*0.8)*1;
                }else if(numLine==1)
                {
                 lines = height + (heightLine)*0
                }else if(numLine<1)
                {
                    lines=height;
                }
                
                
                if (bl == false) //加载样式或线条
                {

                   

                    if (e.type == "ADD_PRINT_IMAGE") {
                       // LODOP.ADD_PRINT_IMAGE(parseInt(e.val1) + height, e.val2, e.val3, e.val4, e.val5)
                    } else if (e.type == "ADD_PRINT_LINE") {

                        if(e.val1!=e.val3)
                        {
                            LODOP.ADD_PRINT_LINE(parseInt(e.val1)+lines, e.val2, parseInt(e.val3), e.val4, e.val5, 2)
                        }else
                        {
                           
                            LODOP.ADD_PRINT_LINE(parseInt(e.val1)+lines, e.val2, parseInt(e.val3) +lines, e.val4, e.val5,2)
                        }

                       // LODOP.ADD_PRINT_LINE(parseInt(e.val1) + height, e.val2, parseInt(e.val3) + height, e.val4, e.val5, e.val6)
                    } else if (e.type == "SET_PRINT_STYLEA") {
                        LODOP.SET_PRINT_STYLEA(e.val1, e.val2, e.val3)
                    }
                }


            })

  
         
            height = (heightLine)+lines;
            numLine=0;
          
            if (PritType === 2 && (j === pageSize - 1 || list.length - 1 === j || list.length === i)) { //套打，表尾位置是不固定的

                 // http://192.168.1.200:555  不启用空白网格功能
                if (pageSize - 1 > j && global.host != "http://192.168.1.200:555") {
                    for (var k = 1; k < pageSize - j; k++) {
                        paramsData.forEach(e => {


                 
                            if (e.type == "ADD_PRINT_IMAGE") {
                               // LODOP.ADD_PRINT_IMAGE(parseInt(e.val1) + height, e.val2, e.val3, e.val4, e.val5)
                            } else if (e.type == "ADD_PRINT_LINE") {
                                //LODOP.ADD_PRINT_LINE(parseInt(e.val1) + heightLine*numLine, e.val2, parseInt(e.val3) + heightLine*numLine, e.val4, e.val5, 4)
                                if(e.val1==e.val3)
                                {
                                    LODOP.ADD_PRINT_LINE(parseInt(e.val1) + height, e.val2, parseInt(e.val3) + height, e.val4, e.val5, 2)
                                }else
                                {
                                    LODOP.ADD_PRINT_LINE(parseInt(e.val1) + height, e.val2, parseInt(e.val3), e.val4, e.val5, 2)
                                }
                                //LODOP.ADD_PRINT_LINE(parseInt(e.val1) + height, e.val2, parseInt(e.val3) + height, e.val4, e.val5, 2)
                            } else if (e.type == "SET_PRINT_STYLEA") {
                                LODOP.SET_PRINT_STYLEA(e.val1, e.val2, e.val3)
                            }
                        })

                        height = height + heightLine;
                    }
                }



           
                addTailData(LODOP, params, templeteData, pageSize, heightLine,height)


            }

            j++;
            i++;


        })

        if (PritType == 1) //连打
        {
            addTailData(LODOP, params, templeteData, list.length, heightLine)
        }

    }
    return LODOP;

}

function computedByteLen(txt) {
    return txt.replace(/[^\x00-\xff]/g, '01').length
  }
//获取对象keys
function getObjKeys(obj) {
    return Object.keys(obj)
}


export async function GetPrintDate(TextType, PrintDate, Date, BillID) {
    let j = 0;
    let type = null;
    var ArrLine = Date.split(";");

    let LineRew = null;
    for (let v in ArrLine) {
        j++
        LineRew = ArrLine[v].replace('(', ',').replace(')', ',');
        var ArrLineRow = LineRew.split(",");
        type = ArrLineRow[0];
        type = type.replace('LODOP.', '');
        type = type.replace(/\n*$/g, '').replace(/\n/g, '').replace(' ', '')
        

        if (type == "SET_PRINT_STYLEA") {
            let row = {
                type: type,
                val1: ArrLineRow[1],
                val2: ArrLineRow[2].replace('"', '').replace('"', ''),
                val3: ArrLineRow[3],
                val4: null,
                val5: null,
                val6: null,
                TextType: TextType,
                TempleteId: BillID
            };

            PrintDate.push(row);
        } else if (type == "ADD_PRINT_LINE") {
            let row = {
                type: type,
                val1: ArrLineRow[1],
                val2: ArrLineRow[2],
                val3: ArrLineRow[3],
                val4: ArrLineRow[4],
                val5: ArrLineRow[5],
                val6: ArrLineRow[6],
                TextType: TextType,
                TempleteId: BillID
            };
            PrintDate.push(row);
        } else if (type == "ADD_PRINT_TEXT" || type == "ADD_PRINT_IMAGE") {
            let row = {
                type: type,
                val1: ArrLineRow[1],
                val2: ArrLineRow[2],
                val3: ArrLineRow[3],
                val4: ArrLineRow[4],
                val5: ArrLineRow[5].replace('"', '').replace('"', ''),
                val6: null,
                TextType: TextType,
                TempleteId: BillID
            };
            PrintDate.push(row);

        }

    }

    return PrintDate;


}



export function GetPrintSetData(data) {
    return request({
        url: '/Common/GetPrintData',
        method: 'post',
        data: data
    })
}